//
//  SISSCommonUploadContractsViewController.m
//  SISSAPP
//
//  Created by 袁应荣 on 2018/12/20.
//  Copyright © 2018 优房网. All rights reserved.
//

#import "SISSCommonUploadContractsViewController.h"
#import "SISSUploadImageView.h"


@interface SISSCommonUploadContractsViewController ()<SISSUploadImageViewDelegate>

/* tipLabel */
@property (weak, nonatomic) UILabel *tipLabel;
@property (weak, nonatomic) SISSUploadImageView *uploadImageView;
@property (weak, nonatomic) UIButton *uploadButton;


@end

@implementation SISSCommonUploadContractsViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
}

#pragma mark - SISSUploadImageViewDelegate
- (void)handlePhotoFinishedAction {
    self.images = self.uploadImageView.images;
}


/**
 确定按钮点击事件
 */
- (void)uploadButtonClickAction {
    
    if (self.images.count == 0) {
        [SISSTools showSVErrorTitle:@"请选择照片" andTime:2 andColor:YES];
        return;
    }
    
}



#pragma mark - UI
- (void)setupSubviews {
    [super setupSubviews];
    
    UILabel *tipLabel = [[UILabel alloc] init];
    tipLabel.textColor = MAIN_TEXT_COLOR;
    tipLabel.font = [UIFont systemFontOfSize:16];
    tipLabel.text = @"温馨提示：请拍照或扫描合同文件后上传。";
    [self.view addSubview:tipLabel];
    self.tipLabel = tipLabel;
    
    // 图片选择
    SISSUploadImageView *uploadImageView = [[SISSUploadImageView alloc] init];
    uploadImageView.isHiddenTitle = YES;
    uploadImageView.delegate = self;
    [self.view addSubview:uploadImageView];
    self.uploadImageView = uploadImageView;
    
    UIButton *uploadButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [uploadButton setTitle:@"上传" forState:UIControlStateNormal];
    [uploadButton setBackgroundColor:MAIN_COLOR];
    [uploadButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    uploadButton.layer.cornerRadius = 22;
    uploadButton.layer.masksToBounds = YES;
    [uploadButton addTarget:self action:@selector(uploadButtonClickAction) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:uploadButton];
    self.uploadButton = uploadButton;
}

// 约束
- (void)initConstraint {
    [super initConstraint];
    WeakSelf
    CGFloat margin = 8.0;
    [self.tipLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.view).offset(kTopHeight + (2 * margin));
        make.left.equalTo(weakSelf.view).offset(2 * margin);
    }];
    
    [self.uploadImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.view);
        make.top.equalTo(weakSelf.tipLabel.mas_bottom);
    }];
    
    [self.uploadButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.view).offset(3 * margin);
        make.top.equalTo(weakSelf.uploadImageView.mas_bottom).offset(margin);
        make.right.equalTo(weakSelf.view).offset(-3 * margin);
        make.height.mas_equalTo(44);
    }];
}

@end
